//
//  PB_CoverTableViewCell.m
//  PalmBus
//
//  Created by 陈李飞 on 17/5/22.
//  Copyright © 2017年 chenlifei. All rights reserved.
//

#import "PB_CoverTableViewCell.h"

@implementation PB_CoverTableViewCell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"PB_CoverTableViewCell";
    PB_CoverTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[PB_CoverTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.selectionStyle          = UITableViewCellSelectionStyleNone;
        cell.backgroundColor         = [UIColor clearColor];
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initCreatUI];
    }
    return self;
}

-(void)initCreatUI
{
    [self addSubview:self.selectButton];
    [self addSubview:self.titileLabel];
    [_selectButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titileLabel);
        make.right.equalTo(self).with.offset(-10);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40);
    }];
    
    [_titileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
         make.left.equalTo(self).with.offset(10);
       // make.left.equalTo(_selectButton.mas_right).with.offset(5);
        make.height.mas_equalTo(30);
        
    }];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
#pragma mark - property

- (UILabel *)titileLabel
{
    if (_titileLabel == nil) {
        _titileLabel = [[UILabel alloc] init];
        _titileLabel.font = MYYFont(16.0f);
        _titileLabel.textColor =MYYtitleColor ;
    }
    return _titileLabel;
}
- (UIButton *)selectButton
{
    if (_selectButton == nil) {
        _selectButton = [[UIButton alloc] init];
        [_selectButton setBackgroundColor:[UIColor clearColor]];
        [_selectButton setImage:[UIImage imageNamed:@"weixuanzhong"] forState:UIControlStateNormal];
        [_selectButton setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateSelected];
        [_selectButton addTarget:self action:@selector(_selectButt:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _selectButton;
}
-(void)_selectButt:(UIButton *)btn
{
    if (self.selectB) {
        self.selectB(btn);
    }
    
}

- (UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [[UIView alloc] init];
    }
    return _bgView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
